<?php

Yii::import('application.models._base.BasePost');

class Post extends BasePost
{
	const STATUS_DRAFT=1;
	const STATUS_PUBLISHED=2;
	const STATUS_ARCHIVED=3;

	/**
	 * @return Post
	 */
	public static function model($className = __CLASS__) {
		return parent::model($className);
	}

	public static function label($n = 1){
		return Yii::t('app', 'Post|Posts', $n);
	}

	public function getUrl() {
		return Yii::app()->createUrl('post/view', array(
            'id'=>$this->id,
            'title'=>$this->title,
		));
	}
	
	public static function generateMenu() {
		$menuArray = array();
		foreach(Post::model()->findAll() as $post) {
			$menu = array(
				'label'=>Yii::t($post->title),
				'url'=>array(''),
				'visible'=>Yii::app()->user->isGuest,
			);
			array_merge($menu, $menuArray);
		}
		return $menuArray;
	}
}